from data_format import x_train,y_train
import pylab as pl
import svm_prediction as sp
import matplotlib.pyplot as plt
import numpy as np

#数据预处理后的可视化
marker_set = ('x', '.')
plt.xlabel('LOC_TOTAL numeric',fontsize=9)
plt.ylabel('LOC_COMMENTS numeric',fontsize=9)
plt.xlim(0, 100)
plt.ylim(0, 100)
for (i,marker) in enumerate(marker_set):
    for j in range(len(y_train)):
        if y_train[j] == i:
            plt.scatter(x_train[j, 0], x_train[j, 2], color='green', marker = marker)
plt.show()

#绘制auc变化
pl.title("AUC change")
pl.ylabel('auc', fontsize=20)
pl.xlabel('times', fontsize=20)
sp.svm_method(x_train, y_train)
pl.legend(loc="lower right")
pl.show()

#绘制roc曲线
sp.draw_roc(x_train, y_train)
plt.plot([0, 1], [0, 1], 'r--')
plt.xlim([-0.1, 1.2])
plt.ylim([-0.1, 1.2])
plt.title('Receiver Operating Characteristic')
plt.legend(loc='lower right')
plt.ylabel('True Positive Rate')
plt.xlabel('False Positive Rate')
plt.show()

#绘制 accurancy，precision，recall，f1数据的直方图
sp.draw_evolution(x_train, y_train)
plt.title('Evaluation indicators')
plt.ylabel('Percent')
plt.yticks(np.arange(0, 1, 0.05))
plt.ylim([0, 1.0])
plt.show()





